package com.apes.framework.plugin.soe.metadata;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 功能：场景变量
 *
 * @author xul
 * @create 2020-06-26 11:45
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = SceneInstanceVariable.CONST_TABLE_NAME, indexes = {
        @Index(columnList = "scene_inst_id, name", unique = true)})
public class SceneInstanceVariable extends BaseModel {
    public static final String CONST_TABLE_NAME = "soe_scene_inst_variable";

    @Id
    @Column(name = "id", length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "场景角色实例")
    @Comment("编码")
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "scene_inst_id", referencedColumnName = "id", nullable = false)
    @Comment("场景实例")
    private SceneInstance sceneInstance;

    @Column(name = "name", nullable = false, length = 120)
    @Comment("变量名称")
    private String name;

    @Column(name = "text", nullable = false, length = 2000)
    @Comment("变量值")
    private String text;

}
